package com.birdcage.goldminer;

import java.util.ArrayList;

import com.birdcage.gamemanagers.GameObject;
import com.birdcage.gamemanagers.GameObjectManager;
import com.birdcage.goldminer.gameobjects.Player;

enum ELevelState {
    eLevelInit,
    eLevelUpdate,
    eLevelExit
}

public class Level {
    
    private int m_curScore;
    private int m_tarScore;
    private int m_time;
    private int m_levelIndex;
//    private Array[Item] m_items; //store item informations
    
    private Player  m_player;
    
    private ELevelState m_curState;
    private ELevelState m_nextState;
    
    private ArrayList<GameObject> m_objects;
    
    private Level m_instance;
    
    public Level GetInstance() {
        if (m_instance == null) {
            m_instance = new Level();
        }
        return m_instance;
    }
    
    
    public void update() {
        if (m_curState != m_nextState) {
            m_curState = m_nextState;
        }
        switch (m_curState) {
        case eLevelInit:
            InitLevel();
            break;
        case eLevelUpdate:
            UpdateLevel();
            break;
        case eLevelExit:
            ExitLevel();
            break;
        default:
            break;
        }
    }
    
    private Level() {
        m_curState = ELevelState.eLevelInit;
        m_nextState = ELevelState.eLevelInit;
    }
    
    private void InitLevel() {
        m_player = new Player(this);
        GameObjectManager.GetInstance().RegisterGameObject(m_player);
    }
    
    private void UpdateLevel() {
        GameObjectManager.GetInstance().Update();
    }
    
    private void ExitLevel() {
        
    }
}